<?php

namespace app\common\service;

use app\common\model\App;
use app\http\exception\AuthException;

class AppService extends BaseService
{
        public function getAppPage( $data ){
            return App::build()->orderBy('app_id' ,'desc')->_paginate();
        }

        public function getAppList( $data ){
            return App::build()->orderBy('app_id' , 'desc')->select();
        }

        public function getAppItem( $app_id ){
            return App::build()->findOrFail($app_id);
        }

        public function delAppItem( $app_id ){
            return App::build()->where('app_id' , $app_id)->delete();
        }

    	public function setAppItem($data , $app_id){
           $info = App::build()->findOrFail($app_id);
           if(!$info){
                throw new AuthException('数据不存在');
           }

           return $info->save($data);
        }


        public function addAppItem($data)
        {
            $model = new App();
            return $model->save($data);
        }


}
